package com.tedu.springmvc01request.controller;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//购物车
@RestController
public class CartController {
	//读取浏览器中的cookie
	@RequestMapping("/add")
	public String add(String itemName,
			HttpServletRequest request) {
		//从request中取cookie
		Cookie[] cookies=request.getCookies();
		String string="";
		if (cookies!=null) {
			for (Cookie cookie:cookies) {
				String name=cookie.getName();
				String content=cookie.getValue();
				string=string+name+"="+content+"<br>";
			}
		}
		return string;
	}

}








